package logic

import (
	"context"
	"house/houseclient"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseInfoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewHouseInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseInfoLogic {
	return &HouseInfoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *HouseInfoLogic) HouseInfo(req *types.HouseInfoRequest) (resp *types.Response, err error) {
	// todo: 详情
	info, err := l.svcCtx.HouseRpc.HouseInfo(l.ctx, &houseclient.HouseInfoReq{
		Id: req.Id,
	})
	if err != nil {
		return &types.Response{
			Code: 500,
			Msg:  err.Error(),
			Data: nil,
		}, nil
	}
	return &types.Response{
		Code: 200,
		Msg:  "详情展示结束",
		Data: info,
	}, nil
}
